package com.wc.算法提高课.C第三章_图论.最小生成树的扩展应用.北极通讯网络;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/10/16 21:42
 * @description https://www.acwing.com/problem/content/1147/
 */
public class Main {
    /**
     * 思路：kruskal 的 k 相当于将最大的那几条边去掉
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 510;
    static int[] p = new int[N];
    static Point[] points = new Point[N];
    static PriorityQueue<Point> heap = new PriorityQueue<>();
    static double[] res = new double[N];
    static int n, k;

    public static void main(String[] args) {
        n = sc.nextInt();
        k = sc.nextInt();
        for (int i = 1; i <= n; i++) {
            int a = sc.nextInt(), b = sc.nextInt();
            points[i] = new Point(a, b, 0);
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j < i; j++) {
                heap.add(new Point(i, j, getDist(i, j)));
            }
        }
        for (int i = 1; i <= n; i++) p[i] = i;
        int cnt = n - 1;
        while (!heap.isEmpty()) {
            Point t = heap.poll();
            int a = find(t.x), b = find(t.y);
            double w = t.w;
            if (a != b) {
                p[a] = b;
                res[cnt--] = w;
            }
        }
        // 这里注意 k == 0的特殊情况
        if (k == 0) k = 1;
        out.printf("%.2f\n", res[k]);
        out.flush();
    }

    static int find(int x) {
        if (p[x] != x) p[x] = find(p[x]);
        return p[x];
    }

    static double getDist(int a, int b) {
        double dx = points[a].x - points[b].x;
        double dy = points[a].y - points[b].y;
        return Math.sqrt(dx * dx + dy * dy);
    }
}

class Point implements Comparable<Point> {
    int x, y;
    double w;

    Point(int x, int y, double w) {
        this.x = x;
        this.y = y;
        this.w = w;
    }

    @Override
    public int compareTo(Point o) {
        return Double.compare(w, o.w);
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
